package top.hkyzf.study.leetcode.array;

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 朱峰
 * @date 2022-1-15 11:11
 */
public class 三个数的最大乘积_628 {
    public int maximumProduct(int[] nums) {
        // 排序
        Arrays.sort(nums);
        int length = nums.length;
        return Math.max(nums[length-1] * nums[length-2] * nums[length-3], nums[0] * nums[1] * nums[length-1]);
    }

    @Test
    public void testMaximumProduct () {
        int [] nums = {1,2,3,4};
        System.out.println(maximumProduct(nums));
    }
}
